package cn.wei.sdd.core.controller.wx;


import cn.wei.common.result.R;
import cn.wei.sdd.base.util.JwtUtils;
import cn.wei.sdd.core.pojo.vo.ExamineVO;
import cn.wei.sdd.core.service.ExamineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 回收员审核表 前端控制器
 * </p>
 *
 * @author Wei
 * @since 2021-10-22
 */
@Api(tags = "回收员")
@RestController
@RequestMapping("/wxApi/core/examine")
public class ExamineController {


    @Autowired
    private ExamineService examineService;

    @ApiOperation("申请成为回收员")
    @PostMapping("/auth/examine")
    public R save(@RequestBody ExamineVO examineVO, HttpServletRequest request){
        String token = request.getHeader("token");
        Long userId = JwtUtils.getUserId(token);
        examineService.SaveExamineVOByUserId(examineVO,userId);
        return R.ok().message("申请成功，请耐心等待");
    }

    @ApiOperation("获取回收员申请状态")
    @GetMapping("/auth/getExamineStatus")
    public R getExamineStatus(HttpServletRequest request){
        String token = request.getHeader("token");
        Long userId = JwtUtils.getUserId(token);
        Integer status = examineService.getExamineStatus(userId);

        return R.ok().data("ExamineStatus",status);
    }

}

